package com.atldy.redis.service.impl;

import com.atldy.redis.service.DianaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * <h2> TODO </h2>
 *
 * @Author: li-dong-yang
 * @CreateTime: 2021-11-10 8:57
 */
@Service
@Slf4j
public class DianaServiceImpl implements DianaService {

    public static final String ARTICLE_KEY = "article:";

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public Long addDiana(Long id) {
        String key = ARTICLE_KEY + id;
        Long increment = stringRedisTemplate.opsForValue().increment(key);
        return increment;
    }

}